package com.sunda.spmsweb.commoncontroller;


import com.sunda.spmscommon.ResponseResult;
import com.sunda.spmscommon.service.ISysLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 系统日志表 前端控制器
 * </p>
 *
 * @author Wayne
 * @since 2020-12-16
 */
@RestController
@RequestMapping("/sysLog")
@Api(tags = "系统日志", description = "系统日志接口")
public class SysLogController {

    @Autowired
    ISysLogService iSysLogService;

    /***
    @RequestMapping("getSysLog")
    @ApiOperation(value = "获取指定类型日志信息",notes = "获取指定类型日志信息logType：1操作日志；2登陆日志；", httpMethod = "POST")
    public ResponseResult getSysLog(String logType,
                                    @RequestParam(defaultValue = "1") int pageNo,
                                    @RequestParam(defaultValue = "10") int pageSize){
        Page<SysLog> page = new Page<>(pageNo,pageSize);
        try{
            return ResponseResult.success().add("sysLog", iSysLogService.getSysLog(page, logType));
        } catch (Exception e){
            return ResponseResult.error("请求异常请重试:" + e);
        }
    }
     ***/

    @RequestMapping("/getSysLogPage")
    @ApiOperation(value = "获取指定类型日志信息",notes = "获取指定类型日志信息logType：1操作日志；2登陆日志；", httpMethod = "POST")
    public ResponseResult getSysLogPage(String logType,
                                    @RequestParam(defaultValue = "1") int pageNo,
                                    @RequestParam(defaultValue = "20") int pageSize){
        try{
            return ResponseResult.success().add("sysLog", iSysLogService.getSysLogPage(pageNo, pageSize, logType));
        } catch (Exception e){
            e.printStackTrace();
            return ResponseResult.error("请求异常请重试:" + e);
        }
    }

    @RequestMapping("/getByUuid")
    @ApiOperation(value = "根据uuid获取日志信息",notes = "根据uuid获取日志信息\n" +
            "uuid = 845ddf1227bb44be87c263b120d3873c", httpMethod = "POST")
    public ResponseResult getByUuid(String uuid){
        try{
            return iSysLogService.getByUuid(uuid);
        } catch (Exception e){
            e.printStackTrace();
            return ResponseResult.error("请求异常请重试:" + e);
        }
    }

}
